var e = require("../../@babel/runtime/helpers/interopRequireDefault"), t = e(require("../../@babel/runtime/regenerator")), r = require("../../@babel/runtime/helpers/asyncToGenerator"), a = e(require("../../http/address")), s = require("../../utils/tool"), i = new a.default(), n = getApp();

Page({
    data: {
        list: []
    },
    onShow: function(e) {
        this.getAddressList();
    },
    getAddressList: function() {
        var e = this;
        return r(t.default.mark(function r() {
            var a;
            return t.default.wrap(function(t) {
                for (;;) switch (t.prev = t.next) {
                  case 0:
                    return n.showLoading(), t.next = 3, i.addressList();

                  case 3:
                    a = t.sent, e.setData({
                        list: a.data.list
                    }), wx.hideLoading();

                  case 6:
                  case "end":
                    return t.stop();
                }
            }, r);
        }))();
    },
    toEditAddress: function() {
        this.data.list.length >= 20 ? (0, s.toastToPage)("收货地址数量已达上限") : wx.navigateTo({
            url: "/pages/edit_address/edit_address"
        });
    },
    goBack: function(e) {
        var t = e.detail.id;
        if ("pages/order_pick/order_pick" == this._getLastUrl()) {
            var r = getCurrentPages();
            r[r.length - 2].setData({
                addressId: t
            }), wx.navigateBack({
                delta: 1
            });
        }
    },
    _getLastUrl: function() {
        var e = getCurrentPages();
        return e[e.length - 2].__route__;
    }
});